<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>vue-resource</title>
</head>
<style>

</style>
<body>
    <div id="app">
       <button @click="get">get请求数据</button>
       <ul>
           <li v-for="book in books" :key="book.id">
               {{book.title}}
           </li>
       </ul>
    </div>      
    <script src="./base/vue.js"></script>
    <script src="https://cdn.bootcss.com/vue-resource/1.3.4/vue-resource.min.js"></script>
    <script>


    //引入vue-resource之后可以在实例/组件上挂载一个$http属性。
    //用这个东西就可以进行数据交互了
    new Vue({
        el:"#app",
        data:{
            books:[]
        },
        methods:{
            get(){
                //借助vue-resource插件实现数据请求
                this.$http.get("./json/temp.json").then(res=>{
                    console.log(res.body.books)
                    this.books = res.body.books
                })
            }
        }
    })

    //   jquery ==> $.ajax({url,type,data,success:()=>{}})
    //   从vue2.0开始，将不对vue-resource进行维护，推荐使用axios  
 
    </script>
</body>
</html>